package com.lxmes.pm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.pm.domain.AProjectManage;
import com.lxmes.pm.service.IAProjectManageService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 校级项目Controller
 * 
 * @author zhangzhiyu
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/pm/projectManage")
public class AProjectManageController extends BaseController
{
    @Autowired
    private IAProjectManageService aProjectManageService;

    /**
     * 查询校级项目列表
     */
    @PreAuthorize("@ss.hasPermi('pm:projectManage:list')")
    @GetMapping("/list")
    public TableDataInfo list(AProjectManage aProjectManage)
    {
        startPage();
        List<AProjectManage> list = aProjectManageService.selectAProjectManageList(aProjectManage);
        return getDataTable(list);
    }

    /**
     * 导出校级项目列表
     */
    @PreAuthorize("@ss.hasPermi('pm:projectManage:export')")
    @Log(title = "校级项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AProjectManage aProjectManage)
    {
        List<AProjectManage> list = aProjectManageService.selectAProjectManageList(aProjectManage);
        ExcelUtil<AProjectManage> util = new ExcelUtil<AProjectManage>(AProjectManage.class);
        util.exportExcel(response, list, "校级项目数据");
    }

    /**
     * 获取校级项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('pm:projectManage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aProjectManageService.selectAProjectManageById(id));
    }

    /**
     * 新增校级项目
     */
    @PreAuthorize("@ss.hasPermi('pm:projectManage:add')")
    @Log(title = "校级项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AProjectManage aProjectManage)
    {
        return toAjax(aProjectManageService.insertAProjectManage(aProjectManage));
    }

    /**
     * 修改校级项目
     */
    @PreAuthorize("@ss.hasPermi('pm:projectManage:edit')")
    @Log(title = "校级项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AProjectManage aProjectManage)
    {
        return toAjax(aProjectManageService.updateAProjectManage(aProjectManage));
    }

    /**
     * 删除校级项目
     */
    @PreAuthorize("@ss.hasPermi('pm:projectManage:remove')")
    @Log(title = "校级项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aProjectManageService.deleteAProjectManageByIds(ids));
    }
}
